<!-- 写到此代码块即可 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <div>
        <button class="jia">+</button>
        <input value="0">
        <button class="jian">-</button>
    </div>
</body>
<script>
    var jia = document.getElementsByClassName('jia')[0]
    var jian = document.getElementsByClassName('jian')[0]
    var val = document.getElementsByTagName('input')[0]
    var num = 0
    jia.onclick = function () {
        num++
        val.value = num
    }

    jian.onclick = function () {
        num--
        val.value = num
    }
</script>

</html>